@extends("layout.main")

@section('content')

    <div class="col-sm-8 blog-main">
        <div class="blog-post">
            <div style="display:inline-flex">
                    <h2 class="blog-post-title">{{$post->title}}</h2>
                    @can('update', $post)
                                        &nbsp&nbsp&nbsp&nbsp&nbsp<a style="margin: auto"  href="/posts/{{$post->id}}/edit">
                        <span class="glyphicon glyphicon-pencil" aria-hidden="true">编辑</span>
                    </a>
                     @endcan
                       @can('delete', $post)

                         &nbsp&nbsp&nbsp&nbsp&nbsp<a style="margin: auto"  href="/posts/{{$post->id}}/delete">
                        <span class="glyphicon glyphicon-remove" aria-hidden="true">删除</span>
                    </a>
                    @endcan

                                </div>

            <p class="blog-post-meta">{{$post->created_at->toFormattedDateString()}} by <a href="#">{{$post->user->name}}</a></p>

            <p><p>{!!$post->content!!}</p><p><br></p></p>
            <div>          
                                   @if(!$post->unzan(Auth::id())->exists())
                                    <a href="/posts/{{$post->id}}/zan" type="button" class="btn btn-primary btn-lg">赞</a>
                                    @else
                                    <a href="/posts/{{$post->id}}/uzan" type="button" class="btn btn-primary btn-lg">取消赞</a>
                                    @endif
        </div>
        @if($post->comments)
      @foreach($post->comments as $c)
       
        <div class="panel panel-default">
            <!-- Default panel contents -->
            <div class="panel-heading">评论</div>

            <!-- List group -->
            <ul class="list-group">
                                <li class="list-group-item">
                    <h5>{{$c->created_at->toFormattedDateString()}} {{$c->user->name}} 
                     </h5>
                    <div>
                            {{$c->comtents}}
                    </div>
                </li>
                            </ul>
        </div>
       @endforeach
       @endif
        <div class="panel panel-default">
            <!-- Default panel contents -->
            <div class="panel-heading">发表评论</div>

            <!-- List group -->
            <ul class="list-group">
                <form action="/posts/{{Auth::user()->id}}/comment" method="post">
                    <input type="hidden" name="_token" value="{{csrf_token()}}">
                     <input type="hidden" name="post_id" value="{{$post->id}}"/>
                    <li class="list-group-item">
                        <textarea name="comtents" class="form-control" rows="10"></textarea>
                        <button class="btn btn-default" type="submit">提交</button>
                    </li>
                </form>

            </ul>
        </div>

    </div><!-- /.blog-main -->

</div>



@endsection()